
class MyClass:
    def __init__(self):
        self.index = 0

    def __next__(self):

        self.index = self.index + 1
        return self.index

    def __iter__(self):
        return self


mycls = MyClass()

while mycls.index < 10:
    print(mycls.index)
    next(mycls)